package com.first.service.Impl;


import com.first.entity.UserEntity;
import com.first.mapper.UserMapper;
import com.first.service.UserService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;

@Service
public class UserServiceImpl implements UserService {

    @Autowired
    private UserMapper userMapper;

    @Override
    public UserEntity registerUser(String userName,String password,String role,String name,String sex,String address)
    {
        userMapper.registerUser(userName,password,role,name,sex,address);
        UserEntity userEntity = new UserEntity();
        userEntity.setName(userName);
        userEntity.setPassword(password);
        userEntity.setRole(role);
        userEntity.setName(name);
        userEntity.setSex(sex);
        userEntity.setAddress(address);
        return userEntity;
    }

    @Override
    public UserEntity loginUser(String userName,String password)
    {
        UserEntity userEntity = userMapper.loginUser(userName,password);
        return userEntity;
    }

    @Override
    public int cancelUser(Integer id)
    {
        int i = userMapper.cancelUser(id);
        return i;
    }
    @Override
    public List<UserEntity> getUsersList()
    {
        List<UserEntity> usersList = userMapper.getUsersList();
        return usersList;
    }

}
